<div class="container">

	<?php echo $this->session->flash(); ?>
			
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">Update Product</h3>
		</div>
		<div class="panel-body">
			
			<?php echo $this->Form->create(null, array('enctype'=>'multipart/form-data', 'url' => array('controller' => 'product', 'action' => 'add'))); ?>
		
				<table>		
					<tr>
						<td style="width:30%; border-bottom:none !important;">
							<div class="panel panel-primary">
							  <div class="panel-body">				   	
									
									<?php echo $this->Form->hidden('id', array('value' => $data['Product']['id'])); ?>
									
									<?php echo $this->Form->input('product_name', array('placeholder' => 'Product name', 'required' => true, 'value' => $data['Product']['product_name'])); ?>
									
									<div class="input select">
										<label for="ProductProductName">Category</label><br>
										<select name="data[Product][category_id]" id="ProductCategoryId">
											
											<?php foreach($category as $cate): ?>
												
												<?php if($cate['Category']['id'] == $data['Product']['category_id']) { ?>
													<option selected="selected" value="<?php echo $cate['Category']['id']; ?>"><?php echo $cate['Category']['category_name']; ?></option>
												<?php } else { ?>
													<option value="<?php echo $cate['Category']['id']; ?>"><?php echo $cate['Category']['category_name']; ?></option>
												<?php } ?>
											<?php endforeach; ?>
											
										</select>
									</div>
						
									<?php echo $this->Form->input('made_in', array('placeholder' => 'Made in', 'required' => true, 'value' => $data['Product']['made_in'])); ?>
						
									<?php echo $this->Form->input('price', array('placeholder' => 'Product price', 'required' => true, 'value' => $data['Product']['price'])); ?>
									<?php echo $this->Form->input('sale_off', array('placeholder' => 'Sale Off Price', 'required' => true, 'value' => $data['Product']['sale_off'])); ?>	
									
									<?php
										
										echo $this->Form->input('special', array('label' => false,
										    'options' => array(0 => 'Normal ', 1 => 'Special'), 'default' => $data['Product']['special']
										));
						 
									?>					
									
							  </div>
							</div>	
						</td>
						
						<td style="border-bottom:none !important;">
							<div class="panel panel-primary">
							  <div class="panel-body">				   	
									
									<?php echo $this->Form->input('description', array('placeholder' => 'Product description', 'required' => true, 'value' => $data['Product']['description'])); ?>	
						
									<?php echo $this->Form->input('detail', array('placeholder' => 'Product detail', 'required' => true, 'value' => $data['Product']['detail'])); ?>														
									
									<?php echo $this->Html->image($data['Product']['sub_img1'], array('width'=>'300px')); ?>									
									<?php echo $this->Form->input('sub_img1', array('type' => 'file', 'label' => false)); ?>
									
									<?php echo $this->Html->image($data['Product']['sub_img2'], array('width'=>'300px')); ?>
									<?php echo $this->Form->input('sub_img2', array('type' => 'file', 'label' => false)); ?>
									
									<?php echo $this->Html->image($data['Product']['sub_img3'], array('width'=>'300px')); ?>
									<?php echo $this->Form->input('sub_img3', array('type' => 'file', 'label' => false)); ?>
									
									<?php echo $this->Form->hidden('img1', array('value' => $data['Product']['sub_img1'])); ?>
									<?php echo $this->Form->hidden('img2', array('value' => $data['Product']['sub_img2'])); ?>
									<?php echo $this->Form->hidden('img3', array('value' => $data['Product']['sub_img3'])); ?>
									
									<a href="<?php echo $this->webroot; ?>product"><button class="btn btn-danger" type="button">Back</button></a>
									<button class="btn btn-primary" type="submit">Update</button>	
							  </div>
							</div>	
						</td>
						
					</tr>
					<tr></tr>
				</table>
			<?php echo $this->Form->end(); ?>
	
		</div>
    </div>
	
</div>